package com.db.stockexchange.demo;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

import com.db.stockexchange.proto.Protocol.ExchangeMessage;

public class SampleServer {
	public static void main(String[] args) {
		try {
			ServerSocket serverSocket = new ServerSocket(8888);
			System.out.println("Waiting for connection...");
			
			Socket clientSocket = serverSocket.accept();
			InputStream is = clientSocket.getInputStream();
			
			ExchangeMessage message = ExchangeMessage.parseDelimitedFrom(is);
			System.out.println("Received message:");
			System.out.println(message);
			
			serverSocket.close();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
